<?php
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
$userid= $_SESSION['iduser'];
include '../connection/connection_crimecar.php';
$comment = $_REQUEST['txtcomment'];
$carnumber = $_REQUEST['checkcarcrime'];
foreach($carnumber as $key => $value){
	$sql = mysql_query("select camera_id from alarm_display where carnumber = '".$value."' ",$connection_crimecar);
	while ($row = mysql_fetch_array($sql)){
		$cameraID[$i] = $row[camera_id] ;
	}
	$sqlinsertcarcrime = "INSERT INTO carcrime(carnum,iUser,cameraID,regDatetime,regNote) 
		VALUES ('$value','$userid','$cameraID[$i]',NOW(),'$comment')";
	mysql_query($sqlinsertcarcrime,$connection_crimecar);
	$deletealarmdisplay = "DELETE FROM alarm_display WHERE carnumber='$value' AND camera_id='$cameraID[$i]'";
	mysql_query($deletealarmdisplay,$connection_crimecar);
	echo $sqlinsertcarcrime;
	echo $deletealarmdisplay;
}
 mysql_close($connection_crimecar);?>